package com.mengtian_tech.tju.dataquery.api.service;

import java.util.Date;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

@Service
public class AsyncDateService {
	@Autowired
	@Qualifier("jdbcTemplateDataAi")
	JdbcTemplate jdbcTemplateDataAi;


	/**
	 * 类型：01-车辆备案；02-干部请假；03-行人进出；04-车辆进出；05-进出学校申请；06-车辆出厂日期
	 */
	public void updateDate(String type,int count) {
		this.jdbcTemplateDataAi.update("UPDATE `data_ai`.`task_update_date` SET  `create_date`=?, `update_count`=?  WHERE (`type`=?)",
				new Date(),count,type);
	}
	
	/**
	 * 获取同步日期
	 */
	public Date getAsyncDate(String type) {
		Map<String, Object> map =  this.jdbcTemplateDataAi.queryForMap("select create_date createdate from task_update_date  where type = ? ",type);
		return (Date) map.get("createdate");
	}

}
